<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function add(a, b, c) {
      return a + b + c
    }
    console.log(add.length);
    // const add = (...arr) => arr.reduce((a, b) => a + b)
    const curry = function (fn) {
      console.log(fn);
      const arr = []
      function result(...arr1) {
        arr.push(...arr1)
        if (fn.length === arr.length) return fn(...arr)
        console.log(arr);
        // console.log(fn.length);
        return result
      }
      return result
    }

    //请实现以下效果


    const res = add(1, 2, 3) // 6
    // console.log(res);
    // console.log(curry);
    // console.log(curry(add)(1)(2)(3));
    // console.log(curry(add)(1));
    // console.log(curry(add)(2));
    // console.log(curry(add)(3));
    let addCurry = curry(add)
    // console.log(curry()());

    // console.log(addCurry);
    const res2 = addCurry(1)(2)(3) // 6
    // console.log(curry(add)(1)(2)(3));
    console.log(res2);
  </script>
</body>

</html>